{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# pandas 进阶修炼 ｜早起Python\n",
    "<br>\n",
    "\n",
    "**本习题由公众号【早起Python & 可视化图鉴】 原创，转载及其他形式合作请与我们联系（微信号`sshs321`)，未经授权严禁搬运及二次创作，侵权必究！**\n",
    "\n",
    "\n",
    "\n",
    "本习题基于 `pandas` 版本 `1.1.3`，所有内容应当在 `Jupyter Notebook` 中执行以获得最佳效果。\n",
    "\n",
    "不同版本之间写法可能会有少许不同，如若碰到此情况，你应该学会如何自行检索解决。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5 - 数据筛选与修改\n",
    "\n",
    "\n",
    "<br>\n",
    "\n",
    "现在，终于来到 `pandas` 数据分析中最**高频**的操作，没有之一————数据的`增删改查`\n",
    "\n",
    "在后面的分组、聚合、透视、可视化等多个操作中，数据的筛选、修改操作也会不断出现。\n",
    "\n",
    "因此在本章节，我整理了 40 余个常用操作\n",
    "\n",
    "以习题的形式，带大家回顾利用 `pandas` 进行数据的增删改查。\n",
    "\n",
    "需要注意的是，**本节中的大部分习题都有两个、三个或者更多的解法**，但我仅提供一个思路。\n",
    "\n",
    "我提供的并非唯一也并非最优的方法，欢迎大家集思广益，加入 pandas 星球来提交你的解答并获得一定奖励。\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 初始化\n",
    "\n",
    "<br>\n",
    "\n",
    "该 `Notebook` 版本为**纯习题版**\n",
    "\n",
    "如果需要答案或者提示，可以微信搜索公众号「早起Python」获取！"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 加载数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "#df = pd.read_html(\"https://olympics.com/tokyo-2020/olympic-games/zh/results/all-sports/medal-standings.htm\")[0]\n",
    "\n",
    "df = pd.read_csv(\"东京奥运会奖牌数据.csv\")  # 如果未联网可以使用这条命令加载数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5-1 数据修改\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1- <font color = '#FB8E00'>数据修改</font>｜列名\n",
    "\n",
    "<br>\n",
    "\n",
    "将原 `df` 列名 `Unnamed: 2`、`Unnamed: 3`、`Unnamed: 4` 修改为 `金牌数`、`银牌数`、`铜牌数`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>86</td>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>86</td>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>86</td>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>86</td>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>86</td>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    排名 国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0    1    美国   39   41   33  113      1     USA\n",
       "1    2    中国   38   32   18   88      2     CHN\n",
       "2    3    日本   27   14   17   58      5     JPN\n",
       "3    4    英国   22   21   22   65      4     GBR\n",
       "4    5   ROC   20   28   23   71      3     ROC\n",
       "..  ..   ...  ...  ...  ...  ...    ...     ...\n",
       "88  86    加纳    0    0    1    1     77     GHA\n",
       "89  86  格林纳达    0    0    1    1     77     GRN\n",
       "90  86   科威特    0    0    1    1     77     KUW\n",
       "91  86  摩尔多瓦    0    0    1    1     77     MDA\n",
       "92  86   叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 8 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.rename(mapper={\"Unnamed: 2\": '金牌数', \"Unnamed: 3\": '银牌数', \"Unnamed: 4\": '铜牌数'}, axis=1, inplace=True)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2 - <font color = '#FB8E00'>数据修改</font>｜行索引\n",
    "\n",
    "<br>\n",
    "\n",
    "将第一列（排名）设置为索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "排名                                         \n",
       "1     美国   39   41   33  113      1     USA\n",
       "2     中国   38   32   18   88      2     CHN\n",
       "3     日本   27   14   17   58      5     JPN\n",
       "4     英国   22   21   22   65      4     GBR\n",
       "5    ROC   20   28   23   71      3     ROC\n",
       "..   ...  ...  ...  ...  ...    ...     ...\n",
       "86    加纳    0    0    1    1     77     GHA\n",
       "86  格林纳达    0    0    1    1     77     GRN\n",
       "86   科威特    0    0    1    1     77     KUW\n",
       "86  摩尔多瓦    0    0    1    1     77     MDA\n",
       "86   叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.set_index('排名', inplace = True)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3 - <font color = '#FB8E00'>数据修改</font>｜修改索引名\n",
    "\n",
    "<br>\n",
    "\n",
    "修改索引名为 金牌排名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "金牌排名                                         \n",
       "1       美国   39   41   33  113      1     USA\n",
       "2       中国   38   32   18   88      2     CHN\n",
       "3       日本   27   14   17   58      5     JPN\n",
       "4       英国   22   21   22   65      4     GBR\n",
       "5      ROC   20   28   23   71      3     ROC\n",
       "...    ...  ...  ...  ...  ...    ...     ...\n",
       "86      加纳    0    0    1    1     77     GHA\n",
       "86    格林纳达    0    0    1    1     77     GRN\n",
       "86     科威特    0    0    1    1     77     KUW\n",
       "86    摩尔多瓦    0    0    1    1     77     MDA\n",
       "86     叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index.rename(\"金牌排名\" ,inplace = True)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4 - <font color = '#FB8E00'>数据修改</font>｜修改值\n",
    "\n",
    "<br>\n",
    "\n",
    "将 ROC（第一列第五行）修改为 俄奥委会"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "金牌排名                                         \n",
       "1       美国   39   41   33  113      1     USA\n",
       "2       中国   38   32   18   88      2     CHN\n",
       "3       日本   27   14   17   58      5     JPN\n",
       "4       英国   22   21   22   65      4     GBR\n",
       "5     俄奥委会   20   28   23   71      3     ROC\n",
       "...    ...  ...  ...  ...  ...    ...     ...\n",
       "86      加纳    0    0    1    1     77     GHA\n",
       "86    格林纳达    0    0    1    1     77     GRN\n",
       "86     科威特    0    0    1    1     77     KUW\n",
       "86    摩尔多瓦    0    0    1    1     77     MDA\n",
       "86     叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[5, '国家奥委会'] = '俄奥委会'\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5 - <font color = '#FB8E00'>数据修改</font>｜替换值（单值）\n",
    "\n",
    "<br>\n",
    "\n",
    "将金牌数列的数字 `0` 替换为 `无`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>无</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会 金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "金牌排名                                        \n",
       "1       美国  39   41   33  113      1     USA\n",
       "2       中国  38   32   18   88      2     CHN\n",
       "3       日本  27   14   17   58      5     JPN\n",
       "4       英国  22   21   22   65      4     GBR\n",
       "5     俄奥委会  20   28   23   71      3     ROC\n",
       "...    ...  ..  ...  ...  ...    ...     ...\n",
       "86      加纳   无    0    1    1     77     GHA\n",
       "86    格林纳达   无    0    1    1     77     GRN\n",
       "86     科威特   无    0    1    1     77     KUW\n",
       "86    摩尔多瓦   无    0    1    1     77     MDA\n",
       "86     叙利亚   无    0    1    1     77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[df.金牌数 == 0, '金牌数'] = '无'\n",
    "data = df\n",
    "df\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6 - <font color = '#FB8E00'>数据修改</font>｜替换值（多值）\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "同时替换\n",
    "\n",
    "- 将 `无` 替换为 缺失值\n",
    "- 将 0 替换为 `None`\n",
    "\n",
    "注意：缺失值的 Nan 该怎么生成？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>&lt;NA&gt;</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会   金牌数   银牌数 铜牌数   总分 按总数排名 国家奥委会代码\n",
       "金牌排名                                         \n",
       "1       美国    39    41  33  113     1     USA\n",
       "2       中国    38    32  18   88     2     CHN\n",
       "3       日本    27    14  17   58     5     JPN\n",
       "4       英国    22    21  22   65     4     GBR\n",
       "5     俄奥委会    20    28  23   71     3     ROC\n",
       "...    ...   ...   ...  ..  ...   ...     ...\n",
       "86      加纳  <NA>  None   1    1    77     GHA\n",
       "86    格林纳达  <NA>  None   1    1    77     GRN\n",
       "86     科威特  <NA>  None   1    1    77     KUW\n",
       "86    摩尔多瓦  <NA>  None   1    1    77     MDA\n",
       "86     叙利亚  <NA>  None   1    1    77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.replace({'无': pd.NA, 0: None},inplace=True)\n",
    "df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "国家奥委会      object\n",
       "金牌数        object\n",
       "银牌数        object\n",
       "铜牌数        object\n",
       "总分         object\n",
       "按总数排名      object\n",
       "国家奥委会代码    object\n",
       "dtype: object"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7 - 数据查看\n",
    "\n",
    "查看各列数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "国家奥委会      object\n",
       "金牌数        object\n",
       "银牌数        object\n",
       "铜牌数        object\n",
       "总分         object\n",
       "按总数排名      object\n",
       "国家奥委会代码    object\n",
       "dtype: object"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 8 - <font color = '#FB8E00'>数据修改</font>｜修改类型\n",
    "\n",
    "将 `金牌数` 列类型修改为 `int`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "国家奥委会      object\n",
       "金牌数         int64\n",
       "银牌数        object\n",
       "铜牌数        object\n",
       "总分         object\n",
       "按总数排名      object\n",
       "国家奥委会代码    object\n",
       "dtype: object"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#df = df.convert_dtypes()\n",
    "df['金牌数'].fillna(0, inplace=True)\n",
    "df.astype({\"金牌数\": int})\n",
    "df.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数   银牌数 铜牌数   总分 按总数排名 国家奥委会代码\n",
       "金牌排名                                        \n",
       "1       美国   39    41  33  113     1     USA\n",
       "2       中国   38    32  18   88     2     CHN\n",
       "3       日本   27    14  17   58     5     JPN\n",
       "4       英国   22    21  22   65     4     GBR\n",
       "5     俄奥委会   20    28  23   71     3     ROC\n",
       "...    ...  ...   ...  ..  ...   ...     ...\n",
       "86      加纳    0  None   1    1    77     GHA\n",
       "86    格林纳达    0  None   1    1    77     GRN\n",
       "86     科威特    0  None   1    1    77     KUW\n",
       "86    摩尔多瓦    0  None   1    1    77     MDA\n",
       "86     叙利亚    0  None   1    1    77     SYR\n",
       "\n",
       "[93 rows x 7 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 9 - <font color = '#1B85FF' >数据增加</font>｜新增列（固定值）\n",
    "\n",
    "<br>\n",
    "\n",
    "**重新加载数据** 并 **新增一列** 比赛地点，值为 `东京`\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "df['比赛地点'] = '东京'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "微信搜索公众号「早起Python」，关注后可以获得更多资源！"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "国家奥委会      object\n",
       "金牌数         int64\n",
       "银牌数        object\n",
       "铜牌数        object\n",
       "总分         object\n",
       "按总数排名      object\n",
       "国家奥委会代码    object\n",
       "比赛地点       object\n",
       "dtype: object"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 10 - <font color = '#1B85FF' >数据增加</font>｜新增列（计算值）\n",
    "\n",
    "<br>\n",
    "\n",
    "**新增一列** 金银牌总数列，值为该国家金银牌总数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>比赛地点</th>\n",
       "      <th>金银牌总数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>东京</td>\n",
       "      <td>80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>东京</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>东京</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>东京</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>东京</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码 比赛地点  金银牌总数\n",
       "金牌排名                                                     \n",
       "1       美国   39   41   33  113      1     USA   东京     80\n",
       "2       中国   38   32   18   88      2     CHN   东京     70\n",
       "3       日本   27   14   17   58      5     JPN   东京     41\n",
       "4       英国   22   21   22   65      4     GBR   东京     43\n",
       "5     俄奥委会   20   28   23   71      3     ROC   东京     48\n",
       "...    ...  ...  ...  ...  ...    ...     ...  ...    ...\n",
       "86      加纳    0    0    1    1     77     GHA   东京      0\n",
       "86    格林纳达    0    0    1    1     77     GRN   东京      0\n",
       "86     科威特    0    0    1    1     77     KUW   东京      0\n",
       "86    摩尔多瓦    0    0    1    1     77     MDA   东京      0\n",
       "86     叙利亚    0    0    1    1     77     SYR   东京      0\n",
       "\n",
       "[93 rows x 9 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.fillna(0, inplace=True)\n",
    "df.convert_dtypes()\n",
    "\n",
    "df['金银牌总数'] = pd.to_numeric(df.金牌数) + df.银牌数\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 11 - <font color = '#1B85FF' >数据增加</font>｜新增列（比较值）\n",
    "\n",
    "新增一列 最多奖牌数量 列，值为该过金银牌数量种最多的一个奖牌数量\n",
    "\n",
    "例如美国银牌最多，则为41，中国为38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>比赛地点</th>\n",
       "      <th>金银牌总数</th>\n",
       "      <th>最多奖牌数量</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>东京</td>\n",
       "      <td>80</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>东京</td>\n",
       "      <td>70</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>东京</td>\n",
       "      <td>41</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>东京</td>\n",
       "      <td>43</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>东京</td>\n",
       "      <td>48</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码 比赛地点  金银牌总数  最多奖牌数量\n",
       "金牌排名                                                             \n",
       "1       美国   39   41   33  113      1     USA   东京     80      41\n",
       "2       中国   38   32   18   88      2     CHN   东京     70      38\n",
       "3       日本   27   14   17   58      5     JPN   东京     41      27\n",
       "4       英国   22   21   22   65      4     GBR   东京     43      22\n",
       "5     俄奥委会   20   28   23   71      3     ROC   东京     48      28\n",
       "...    ...  ...  ...  ...  ...    ...     ...  ...    ...     ...\n",
       "86      加纳    0    0    1    1     77     GHA   东京      0       1\n",
       "86    格林纳达    0    0    1    1     77     GRN   东京      0       1\n",
       "86     科威特    0    0    1    1     77     KUW   东京      0       1\n",
       "86    摩尔多瓦    0    0    1    1     77     MDA   东京      0       1\n",
       "86     叙利亚    0    0    1    1     77     SYR   东京      0       1\n",
       "\n",
       "[93 rows x 10 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['最多奖牌数量'] = df[['金牌数', '银牌数', '铜牌数']].max(axis=1)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 12 - <font color = '#1B85FF' >数据增加</font>｜新增列（判断值）\n",
    "\n",
    "新增一列 金牌大于30\n",
    "\n",
    "如果一个国家的金牌数大于 30 则值为 是，反之为 否"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>比赛地点</th>\n",
       "      <th>金银牌总数</th>\n",
       "      <th>最多奖牌数量</th>\n",
       "      <th>金牌数大于30</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>东京</td>\n",
       "      <td>80</td>\n",
       "      <td>41</td>\n",
       "      <td>是</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>东京</td>\n",
       "      <td>70</td>\n",
       "      <td>38</td>\n",
       "      <td>是</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>东京</td>\n",
       "      <td>41</td>\n",
       "      <td>27</td>\n",
       "      <td>否</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>东京</td>\n",
       "      <td>43</td>\n",
       "      <td>22</td>\n",
       "      <td>否</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>东京</td>\n",
       "      <td>48</td>\n",
       "      <td>28</td>\n",
       "      <td>否</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码 比赛地点  金银牌总数  最多奖牌数量 金牌数大于30\n",
       "金牌排名                                                                     \n",
       "1       美国   39   41   33  113      1     USA   东京     80      41       是\n",
       "2       中国   38   32   18   88      2     CHN   东京     70      38       是\n",
       "3       日本   27   14   17   58      5     JPN   东京     41      27       否\n",
       "4       英国   22   21   22   65      4     GBR   东京     43      22       否\n",
       "5     俄奥委会   20   28   23   71      3     ROC   东京     48      28       否\n",
       "...    ...  ...  ...  ...  ...    ...     ...  ...    ...     ...     ...\n",
       "86      加纳    0    0    1    1     77     GHA   东京      0       1       否\n",
       "86    格林纳达    0    0    1    1     77     GRN   东京      0       1       否\n",
       "86     科威特    0    0    1    1     77     KUW   东京      0       1       否\n",
       "86    摩尔多瓦    0    0    1    1     77     MDA   东京      0       1       否\n",
       "86     叙利亚    0    0    1    1     77     SYR   东京      0       1       否\n",
       "\n",
       "[93 rows x 11 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['金牌数大于30'] =  df.金牌数 > 30\n",
    "df['金牌数大于30'].replace({True: '是', False: '否'},inplace=True)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 13 - <font color = '#1B85FF' >数据增加</font>｜增加多列\n",
    "\n",
    "新增两列，分别是\n",
    "\n",
    "- 金铜牌总数（金牌数+铜牌数）\n",
    "- 银铜牌总数（银牌数+铜牌数）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>比赛地点</th>\n",
       "      <th>金银牌总数</th>\n",
       "      <th>最多奖牌数量</th>\n",
       "      <th>金牌数大于30</th>\n",
       "      <th>金铜牌总数</th>\n",
       "      <th>银铜牌总数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>东京</td>\n",
       "      <td>80</td>\n",
       "      <td>41</td>\n",
       "      <td>是</td>\n",
       "      <td>72</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>东京</td>\n",
       "      <td>70</td>\n",
       "      <td>38</td>\n",
       "      <td>是</td>\n",
       "      <td>56</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>东京</td>\n",
       "      <td>41</td>\n",
       "      <td>27</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>东京</td>\n",
       "      <td>43</td>\n",
       "      <td>22</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>东京</td>\n",
       "      <td>48</td>\n",
       "      <td>28</td>\n",
       "      <td>否</td>\n",
       "      <td>43</td>\n",
       "      <td>51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 13 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码 比赛地点  金银牌总数  最多奖牌数量 金牌数大于30  \\\n",
       "金牌排名                                                                        \n",
       "1       美国   39   41   33  113      1     USA   东京     80      41       是   \n",
       "2       中国   38   32   18   88      2     CHN   东京     70      38       是   \n",
       "3       日本   27   14   17   58      5     JPN   东京     41      27       否   \n",
       "4       英国   22   21   22   65      4     GBR   东京     43      22       否   \n",
       "5     俄奥委会   20   28   23   71      3     ROC   东京     48      28       否   \n",
       "...    ...  ...  ...  ...  ...    ...     ...  ...    ...     ...     ...   \n",
       "86      加纳    0    0    1    1     77     GHA   东京      0       1       否   \n",
       "86    格林纳达    0    0    1    1     77     GRN   东京      0       1       否   \n",
       "86     科威特    0    0    1    1     77     KUW   东京      0       1       否   \n",
       "86    摩尔多瓦    0    0    1    1     77     MDA   东京      0       1       否   \n",
       "86     叙利亚    0    0    1    1     77     SYR   东京      0       1       否   \n",
       "\n",
       "      金铜牌总数  银铜牌总数  \n",
       "金牌排名                \n",
       "1        72     74  \n",
       "2        56     50  \n",
       "3        44     31  \n",
       "4        44     43  \n",
       "5        43     51  \n",
       "...     ...    ...  \n",
       "86        1      1  \n",
       "86        1      1  \n",
       "86        1      1  \n",
       "86        1      1  \n",
       "86        1      1  \n",
       "\n",
       "[93 rows x 13 columns]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"金铜牌总数\"] = df.金牌数  + df.铜牌数\n",
    "df[\"银铜牌总数\"] = df.银牌数  + df.铜牌数\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 14 - <font color = '#1B85FF' >数据增加</font>｜新增列（引用变量）\n",
    "\n",
    "新增一列金牌占比，为各国金牌数除以总金牌数（gold_sum）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "#T_153e5_row0_col13 {\n",
       "  width: 10em;\n",
       "  height: 80%;\n",
       "  background: linear-gradient(90deg,#d65f5f 57.4%, transparent 57.4%);\n",
       "}\n",
       "#T_153e5_row1_col13 {\n",
       "  width: 10em;\n",
       "  height: 80%;\n",
       "  background: linear-gradient(90deg,#d65f5f 55.9%, transparent 55.9%);\n",
       "}\n",
       "#T_153e5_row2_col13 {\n",
       "  width: 10em;\n",
       "  height: 80%;\n",
       "  background: linear-gradient(90deg,#d65f5f 39.7%, transparent 39.7%);\n",
       "}\n",
       "#T_153e5_row3_col13 {\n",
       "  width: 10em;\n",
       "  height: 80%;\n",
       "  background: linear-gradient(90deg,#d65f5f 32.4%, transparent 32.4%);\n",
       "}\n",
       "#T_153e5_row4_col13 {\n",
       "  width: 10em;\n",
       "  height: 80%;\n",
       "  background: linear-gradient(90deg,#d65f5f 29.4%, transparent 29.4%);\n",
       "}\n",
       "#T_153e5_row5_col13 {\n",
       "  width: 10em;\n",
       "  height: 80%;\n",
       "  background: linear-gradient(90deg,#d65f5f 25.0%, transparent 25.0%);\n",
       "}\n",
       "#T_153e5_row6_col13, #T_153e5_row7_col13, #T_153e5_row8_col13, #T_153e5_row9_col13 {\n",
       "  width: 10em;\n",
       "  height: 80%;\n",
       "  background: linear-gradient(90deg,#d65f5f 14.7%, transparent 14.7%);\n",
       "}\n",
       "</style>\n",
       "<table id=\"T_153e5_\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th class=\"col_heading level0 col0\" >国家奥委会</th>\n",
       "      <th class=\"col_heading level0 col1\" >金牌数</th>\n",
       "      <th class=\"col_heading level0 col2\" >银牌数</th>\n",
       "      <th class=\"col_heading level0 col3\" >铜牌数</th>\n",
       "      <th class=\"col_heading level0 col4\" >总分</th>\n",
       "      <th class=\"col_heading level0 col5\" >按总数排名</th>\n",
       "      <th class=\"col_heading level0 col6\" >国家奥委会代码</th>\n",
       "      <th class=\"col_heading level0 col7\" >比赛地点</th>\n",
       "      <th class=\"col_heading level0 col8\" >金银牌总数</th>\n",
       "      <th class=\"col_heading level0 col9\" >最多奖牌数量</th>\n",
       "      <th class=\"col_heading level0 col10\" >金牌数大于30</th>\n",
       "      <th class=\"col_heading level0 col11\" >金铜牌总数</th>\n",
       "      <th class=\"col_heading level0 col12\" >银铜牌总数</th>\n",
       "      <th class=\"col_heading level0 col13\" >金牌占比</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th class=\"index_name level0\" >金牌排名</th>\n",
       "      <th class=\"blank col0\" >&nbsp;</th>\n",
       "      <th class=\"blank col1\" >&nbsp;</th>\n",
       "      <th class=\"blank col2\" >&nbsp;</th>\n",
       "      <th class=\"blank col3\" >&nbsp;</th>\n",
       "      <th class=\"blank col4\" >&nbsp;</th>\n",
       "      <th class=\"blank col5\" >&nbsp;</th>\n",
       "      <th class=\"blank col6\" >&nbsp;</th>\n",
       "      <th class=\"blank col7\" >&nbsp;</th>\n",
       "      <th class=\"blank col8\" >&nbsp;</th>\n",
       "      <th class=\"blank col9\" >&nbsp;</th>\n",
       "      <th class=\"blank col10\" >&nbsp;</th>\n",
       "      <th class=\"blank col11\" >&nbsp;</th>\n",
       "      <th class=\"blank col12\" >&nbsp;</th>\n",
       "      <th class=\"blank col13\" >&nbsp;</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row0\" class=\"row_heading level0 row0\" >1</th>\n",
       "      <td id=\"T_153e5_row0_col0\" class=\"data row0 col0\" >美国</td>\n",
       "      <td id=\"T_153e5_row0_col1\" class=\"data row0 col1\" >39</td>\n",
       "      <td id=\"T_153e5_row0_col2\" class=\"data row0 col2\" >41</td>\n",
       "      <td id=\"T_153e5_row0_col3\" class=\"data row0 col3\" >33</td>\n",
       "      <td id=\"T_153e5_row0_col4\" class=\"data row0 col4\" >113</td>\n",
       "      <td id=\"T_153e5_row0_col5\" class=\"data row0 col5\" >1</td>\n",
       "      <td id=\"T_153e5_row0_col6\" class=\"data row0 col6\" >USA</td>\n",
       "      <td id=\"T_153e5_row0_col7\" class=\"data row0 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row0_col8\" class=\"data row0 col8\" >80</td>\n",
       "      <td id=\"T_153e5_row0_col9\" class=\"data row0 col9\" >41</td>\n",
       "      <td id=\"T_153e5_row0_col10\" class=\"data row0 col10\" >是</td>\n",
       "      <td id=\"T_153e5_row0_col11\" class=\"data row0 col11\" >72</td>\n",
       "      <td id=\"T_153e5_row0_col12\" class=\"data row0 col12\" >74</td>\n",
       "      <td id=\"T_153e5_row0_col13\" class=\"data row0 col13\" >0.114706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row1\" class=\"row_heading level0 row1\" >2</th>\n",
       "      <td id=\"T_153e5_row1_col0\" class=\"data row1 col0\" >中国</td>\n",
       "      <td id=\"T_153e5_row1_col1\" class=\"data row1 col1\" >38</td>\n",
       "      <td id=\"T_153e5_row1_col2\" class=\"data row1 col2\" >32</td>\n",
       "      <td id=\"T_153e5_row1_col3\" class=\"data row1 col3\" >18</td>\n",
       "      <td id=\"T_153e5_row1_col4\" class=\"data row1 col4\" >88</td>\n",
       "      <td id=\"T_153e5_row1_col5\" class=\"data row1 col5\" >2</td>\n",
       "      <td id=\"T_153e5_row1_col6\" class=\"data row1 col6\" >CHN</td>\n",
       "      <td id=\"T_153e5_row1_col7\" class=\"data row1 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row1_col8\" class=\"data row1 col8\" >70</td>\n",
       "      <td id=\"T_153e5_row1_col9\" class=\"data row1 col9\" >38</td>\n",
       "      <td id=\"T_153e5_row1_col10\" class=\"data row1 col10\" >是</td>\n",
       "      <td id=\"T_153e5_row1_col11\" class=\"data row1 col11\" >56</td>\n",
       "      <td id=\"T_153e5_row1_col12\" class=\"data row1 col12\" >50</td>\n",
       "      <td id=\"T_153e5_row1_col13\" class=\"data row1 col13\" >0.111765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row2\" class=\"row_heading level0 row2\" >3</th>\n",
       "      <td id=\"T_153e5_row2_col0\" class=\"data row2 col0\" >日本</td>\n",
       "      <td id=\"T_153e5_row2_col1\" class=\"data row2 col1\" >27</td>\n",
       "      <td id=\"T_153e5_row2_col2\" class=\"data row2 col2\" >14</td>\n",
       "      <td id=\"T_153e5_row2_col3\" class=\"data row2 col3\" >17</td>\n",
       "      <td id=\"T_153e5_row2_col4\" class=\"data row2 col4\" >58</td>\n",
       "      <td id=\"T_153e5_row2_col5\" class=\"data row2 col5\" >5</td>\n",
       "      <td id=\"T_153e5_row2_col6\" class=\"data row2 col6\" >JPN</td>\n",
       "      <td id=\"T_153e5_row2_col7\" class=\"data row2 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row2_col8\" class=\"data row2 col8\" >41</td>\n",
       "      <td id=\"T_153e5_row2_col9\" class=\"data row2 col9\" >27</td>\n",
       "      <td id=\"T_153e5_row2_col10\" class=\"data row2 col10\" >否</td>\n",
       "      <td id=\"T_153e5_row2_col11\" class=\"data row2 col11\" >44</td>\n",
       "      <td id=\"T_153e5_row2_col12\" class=\"data row2 col12\" >31</td>\n",
       "      <td id=\"T_153e5_row2_col13\" class=\"data row2 col13\" >0.079412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row3\" class=\"row_heading level0 row3\" >4</th>\n",
       "      <td id=\"T_153e5_row3_col0\" class=\"data row3 col0\" >英国</td>\n",
       "      <td id=\"T_153e5_row3_col1\" class=\"data row3 col1\" >22</td>\n",
       "      <td id=\"T_153e5_row3_col2\" class=\"data row3 col2\" >21</td>\n",
       "      <td id=\"T_153e5_row3_col3\" class=\"data row3 col3\" >22</td>\n",
       "      <td id=\"T_153e5_row3_col4\" class=\"data row3 col4\" >65</td>\n",
       "      <td id=\"T_153e5_row3_col5\" class=\"data row3 col5\" >4</td>\n",
       "      <td id=\"T_153e5_row3_col6\" class=\"data row3 col6\" >GBR</td>\n",
       "      <td id=\"T_153e5_row3_col7\" class=\"data row3 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row3_col8\" class=\"data row3 col8\" >43</td>\n",
       "      <td id=\"T_153e5_row3_col9\" class=\"data row3 col9\" >22</td>\n",
       "      <td id=\"T_153e5_row3_col10\" class=\"data row3 col10\" >否</td>\n",
       "      <td id=\"T_153e5_row3_col11\" class=\"data row3 col11\" >44</td>\n",
       "      <td id=\"T_153e5_row3_col12\" class=\"data row3 col12\" >43</td>\n",
       "      <td id=\"T_153e5_row3_col13\" class=\"data row3 col13\" >0.064706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row4\" class=\"row_heading level0 row4\" >5</th>\n",
       "      <td id=\"T_153e5_row4_col0\" class=\"data row4 col0\" >俄奥委会</td>\n",
       "      <td id=\"T_153e5_row4_col1\" class=\"data row4 col1\" >20</td>\n",
       "      <td id=\"T_153e5_row4_col2\" class=\"data row4 col2\" >28</td>\n",
       "      <td id=\"T_153e5_row4_col3\" class=\"data row4 col3\" >23</td>\n",
       "      <td id=\"T_153e5_row4_col4\" class=\"data row4 col4\" >71</td>\n",
       "      <td id=\"T_153e5_row4_col5\" class=\"data row4 col5\" >3</td>\n",
       "      <td id=\"T_153e5_row4_col6\" class=\"data row4 col6\" >ROC</td>\n",
       "      <td id=\"T_153e5_row4_col7\" class=\"data row4 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row4_col8\" class=\"data row4 col8\" >48</td>\n",
       "      <td id=\"T_153e5_row4_col9\" class=\"data row4 col9\" >28</td>\n",
       "      <td id=\"T_153e5_row4_col10\" class=\"data row4 col10\" >否</td>\n",
       "      <td id=\"T_153e5_row4_col11\" class=\"data row4 col11\" >43</td>\n",
       "      <td id=\"T_153e5_row4_col12\" class=\"data row4 col12\" >51</td>\n",
       "      <td id=\"T_153e5_row4_col13\" class=\"data row4 col13\" >0.058824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row5\" class=\"row_heading level0 row5\" >6</th>\n",
       "      <td id=\"T_153e5_row5_col0\" class=\"data row5 col0\" >澳大利亚</td>\n",
       "      <td id=\"T_153e5_row5_col1\" class=\"data row5 col1\" >17</td>\n",
       "      <td id=\"T_153e5_row5_col2\" class=\"data row5 col2\" >7</td>\n",
       "      <td id=\"T_153e5_row5_col3\" class=\"data row5 col3\" >22</td>\n",
       "      <td id=\"T_153e5_row5_col4\" class=\"data row5 col4\" >46</td>\n",
       "      <td id=\"T_153e5_row5_col5\" class=\"data row5 col5\" >6</td>\n",
       "      <td id=\"T_153e5_row5_col6\" class=\"data row5 col6\" >AUS</td>\n",
       "      <td id=\"T_153e5_row5_col7\" class=\"data row5 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row5_col8\" class=\"data row5 col8\" >24</td>\n",
       "      <td id=\"T_153e5_row5_col9\" class=\"data row5 col9\" >22</td>\n",
       "      <td id=\"T_153e5_row5_col10\" class=\"data row5 col10\" >否</td>\n",
       "      <td id=\"T_153e5_row5_col11\" class=\"data row5 col11\" >39</td>\n",
       "      <td id=\"T_153e5_row5_col12\" class=\"data row5 col12\" >29</td>\n",
       "      <td id=\"T_153e5_row5_col13\" class=\"data row5 col13\" >0.050000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row6\" class=\"row_heading level0 row6\" >7</th>\n",
       "      <td id=\"T_153e5_row6_col0\" class=\"data row6 col0\" >荷兰</td>\n",
       "      <td id=\"T_153e5_row6_col1\" class=\"data row6 col1\" >10</td>\n",
       "      <td id=\"T_153e5_row6_col2\" class=\"data row6 col2\" >12</td>\n",
       "      <td id=\"T_153e5_row6_col3\" class=\"data row6 col3\" >14</td>\n",
       "      <td id=\"T_153e5_row6_col4\" class=\"data row6 col4\" >36</td>\n",
       "      <td id=\"T_153e5_row6_col5\" class=\"data row6 col5\" >9</td>\n",
       "      <td id=\"T_153e5_row6_col6\" class=\"data row6 col6\" >NED</td>\n",
       "      <td id=\"T_153e5_row6_col7\" class=\"data row6 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row6_col8\" class=\"data row6 col8\" >22</td>\n",
       "      <td id=\"T_153e5_row6_col9\" class=\"data row6 col9\" >14</td>\n",
       "      <td id=\"T_153e5_row6_col10\" class=\"data row6 col10\" >否</td>\n",
       "      <td id=\"T_153e5_row6_col11\" class=\"data row6 col11\" >24</td>\n",
       "      <td id=\"T_153e5_row6_col12\" class=\"data row6 col12\" >26</td>\n",
       "      <td id=\"T_153e5_row6_col13\" class=\"data row6 col13\" >0.029412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row7\" class=\"row_heading level0 row7\" >8</th>\n",
       "      <td id=\"T_153e5_row7_col0\" class=\"data row7 col0\" >法国</td>\n",
       "      <td id=\"T_153e5_row7_col1\" class=\"data row7 col1\" >10</td>\n",
       "      <td id=\"T_153e5_row7_col2\" class=\"data row7 col2\" >12</td>\n",
       "      <td id=\"T_153e5_row7_col3\" class=\"data row7 col3\" >11</td>\n",
       "      <td id=\"T_153e5_row7_col4\" class=\"data row7 col4\" >33</td>\n",
       "      <td id=\"T_153e5_row7_col5\" class=\"data row7 col5\" >10</td>\n",
       "      <td id=\"T_153e5_row7_col6\" class=\"data row7 col6\" >FRA</td>\n",
       "      <td id=\"T_153e5_row7_col7\" class=\"data row7 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row7_col8\" class=\"data row7 col8\" >22</td>\n",
       "      <td id=\"T_153e5_row7_col9\" class=\"data row7 col9\" >12</td>\n",
       "      <td id=\"T_153e5_row7_col10\" class=\"data row7 col10\" >否</td>\n",
       "      <td id=\"T_153e5_row7_col11\" class=\"data row7 col11\" >21</td>\n",
       "      <td id=\"T_153e5_row7_col12\" class=\"data row7 col12\" >23</td>\n",
       "      <td id=\"T_153e5_row7_col13\" class=\"data row7 col13\" >0.029412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row8\" class=\"row_heading level0 row8\" >9</th>\n",
       "      <td id=\"T_153e5_row8_col0\" class=\"data row8 col0\" >德国</td>\n",
       "      <td id=\"T_153e5_row8_col1\" class=\"data row8 col1\" >10</td>\n",
       "      <td id=\"T_153e5_row8_col2\" class=\"data row8 col2\" >11</td>\n",
       "      <td id=\"T_153e5_row8_col3\" class=\"data row8 col3\" >16</td>\n",
       "      <td id=\"T_153e5_row8_col4\" class=\"data row8 col4\" >37</td>\n",
       "      <td id=\"T_153e5_row8_col5\" class=\"data row8 col5\" >8</td>\n",
       "      <td id=\"T_153e5_row8_col6\" class=\"data row8 col6\" >GER</td>\n",
       "      <td id=\"T_153e5_row8_col7\" class=\"data row8 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row8_col8\" class=\"data row8 col8\" >21</td>\n",
       "      <td id=\"T_153e5_row8_col9\" class=\"data row8 col9\" >16</td>\n",
       "      <td id=\"T_153e5_row8_col10\" class=\"data row8 col10\" >否</td>\n",
       "      <td id=\"T_153e5_row8_col11\" class=\"data row8 col11\" >26</td>\n",
       "      <td id=\"T_153e5_row8_col12\" class=\"data row8 col12\" >27</td>\n",
       "      <td id=\"T_153e5_row8_col13\" class=\"data row8 col13\" >0.029412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_153e5_level0_row9\" class=\"row_heading level0 row9\" >10</th>\n",
       "      <td id=\"T_153e5_row9_col0\" class=\"data row9 col0\" >意大利</td>\n",
       "      <td id=\"T_153e5_row9_col1\" class=\"data row9 col1\" >10</td>\n",
       "      <td id=\"T_153e5_row9_col2\" class=\"data row9 col2\" >10</td>\n",
       "      <td id=\"T_153e5_row9_col3\" class=\"data row9 col3\" >20</td>\n",
       "      <td id=\"T_153e5_row9_col4\" class=\"data row9 col4\" >40</td>\n",
       "      <td id=\"T_153e5_row9_col5\" class=\"data row9 col5\" >7</td>\n",
       "      <td id=\"T_153e5_row9_col6\" class=\"data row9 col6\" >ITA</td>\n",
       "      <td id=\"T_153e5_row9_col7\" class=\"data row9 col7\" >东京</td>\n",
       "      <td id=\"T_153e5_row9_col8\" class=\"data row9 col8\" >20</td>\n",
       "      <td id=\"T_153e5_row9_col9\" class=\"data row9 col9\" >20</td>\n",
       "      <td id=\"T_153e5_row9_col10\" class=\"data row9 col10\" >否</td>\n",
       "      <td id=\"T_153e5_row9_col11\" class=\"data row9 col11\" >30</td>\n",
       "      <td id=\"T_153e5_row9_col12\" class=\"data row9 col12\" >30</td>\n",
       "      <td id=\"T_153e5_row9_col13\" class=\"data row9 col13\" >0.029412</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x7fdc53e7a9b0>"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "god_sum = df.金牌数.sum()\n",
    "df['金牌占比'] = df.金牌数 / god_sum\n",
    "df[:10].style.bar(subset=['金牌占比'], vmin=0, vmax=0.2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 15 - <font color = '#1B85FF' >数据增加</font>｜新增行（末尾追加）\n",
    "\n",
    "<br>\n",
    "\n",
    "在 df 末尾追加一行，内容为 0,1,2,3... 一直到 `df` 的列长度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.loc[len(df)] = [i for i in range(len(df.columns))]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 16 - <font color = '#1B85FF' >数据增加</font>｜新增行（指定位置）\n",
    "\n",
    "<br>\n",
    "\n",
    "在第 2 行新增一行数据，即美国和中国之间。\n",
    "\n",
    "数据内容同上一题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>比赛地点</th>\n",
       "      <th>金银牌总数</th>\n",
       "      <th>最多奖牌数量</th>\n",
       "      <th>金牌数大于30</th>\n",
       "      <th>金铜牌总数</th>\n",
       "      <th>银铜牌总数</th>\n",
       "      <th>金牌占比</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>东京</td>\n",
       "      <td>80</td>\n",
       "      <td>41</td>\n",
       "      <td>是</td>\n",
       "      <td>72</td>\n",
       "      <td>74</td>\n",
       "      <td>0.114706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>东京</td>\n",
       "      <td>70</td>\n",
       "      <td>38</td>\n",
       "      <td>是</td>\n",
       "      <td>56</td>\n",
       "      <td>50</td>\n",
       "      <td>0.111765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>东京</td>\n",
       "      <td>41</td>\n",
       "      <td>27</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>31</td>\n",
       "      <td>0.079412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>东京</td>\n",
       "      <td>43</td>\n",
       "      <td>22</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>43</td>\n",
       "      <td>0.064706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>东京</td>\n",
       "      <td>48</td>\n",
       "      <td>28</td>\n",
       "      <td>否</td>\n",
       "      <td>43</td>\n",
       "      <td>51</td>\n",
       "      <td>0.058824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>93</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>13.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>94 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码 比赛地点  金银牌总数  最多奖牌数量 金牌数大于30  \\\n",
       "金牌排名                                                                        \n",
       "1       美国   39   41   33  113      1     USA   东京     80      41       是   \n",
       "2       中国   38   32   18   88      2     CHN   东京     70      38       是   \n",
       "3       日本   27   14   17   58      5     JPN   东京     41      27       否   \n",
       "4       英国   22   21   22   65      4     GBR   东京     43      22       否   \n",
       "5     俄奥委会   20   28   23   71      3     ROC   东京     48      28       否   \n",
       "...    ...  ...  ...  ...  ...    ...     ...  ...    ...     ...     ...   \n",
       "86    格林纳达    0    0    1    1     77     GRN   东京      0       1       否   \n",
       "86     科威特    0    0    1    1     77     KUW   东京      0       1       否   \n",
       "86    摩尔多瓦    0    0    1    1     77     MDA   东京      0       1       否   \n",
       "86     叙利亚    0    0    1    1     77     SYR   东京      0       1       否   \n",
       "93       0    1    2    3    4      5       6    7      8       9      10   \n",
       "\n",
       "      金铜牌总数  银铜牌总数       金牌占比  \n",
       "金牌排名                           \n",
       "1        72     74   0.114706  \n",
       "2        56     50   0.111765  \n",
       "3        44     31   0.079412  \n",
       "4        44     43   0.064706  \n",
       "5        43     51   0.058824  \n",
       "...     ...    ...        ...  \n",
       "86        1      1   0.000000  \n",
       "86        1      1   0.000000  \n",
       "86        1      1   0.000000  \n",
       "86        1      1   0.000000  \n",
       "93       11     12  13.000000  \n",
       "\n",
       "[94 rows x 14 columns]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 17 - <font color ='#27BE49'>数据删除</font>｜删除行\n",
    "\n",
    "<br>\n",
    "\n",
    "删除 `df` 第一行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>比赛地点</th>\n",
       "      <th>金银牌总数</th>\n",
       "      <th>最多奖牌数量</th>\n",
       "      <th>金牌数大于30</th>\n",
       "      <th>金铜牌总数</th>\n",
       "      <th>银铜牌总数</th>\n",
       "      <th>金牌占比</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>东京</td>\n",
       "      <td>80</td>\n",
       "      <td>41</td>\n",
       "      <td>是</td>\n",
       "      <td>72</td>\n",
       "      <td>74</td>\n",
       "      <td>0.114706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>东京</td>\n",
       "      <td>70</td>\n",
       "      <td>38</td>\n",
       "      <td>是</td>\n",
       "      <td>56</td>\n",
       "      <td>50</td>\n",
       "      <td>0.111765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>东京</td>\n",
       "      <td>41</td>\n",
       "      <td>27</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>31</td>\n",
       "      <td>0.079412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>东京</td>\n",
       "      <td>43</td>\n",
       "      <td>22</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>43</td>\n",
       "      <td>0.064706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>东京</td>\n",
       "      <td>48</td>\n",
       "      <td>28</td>\n",
       "      <td>否</td>\n",
       "      <td>43</td>\n",
       "      <td>51</td>\n",
       "      <td>0.058824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>东京</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码 比赛地点  金银牌总数  最多奖牌数量 金牌数大于30  \\\n",
       "金牌排名                                                                        \n",
       "1       美国   39   41   33  113      1     USA   东京     80      41       是   \n",
       "2       中国   38   32   18   88      2     CHN   东京     70      38       是   \n",
       "3       日本   27   14   17   58      5     JPN   东京     41      27       否   \n",
       "4       英国   22   21   22   65      4     GBR   东京     43      22       否   \n",
       "5     俄奥委会   20   28   23   71      3     ROC   东京     48      28       否   \n",
       "...    ...  ...  ...  ...  ...    ...     ...  ...    ...     ...     ...   \n",
       "86      加纳    0    0    1    1     77     GHA   东京      0       1       否   \n",
       "86    格林纳达    0    0    1    1     77     GRN   东京      0       1       否   \n",
       "86     科威特    0    0    1    1     77     KUW   东京      0       1       否   \n",
       "86    摩尔多瓦    0    0    1    1     77     MDA   东京      0       1       否   \n",
       "86     叙利亚    0    0    1    1     77     SYR   东京      0       1       否   \n",
       "\n",
       "      金铜牌总数  银铜牌总数      金牌占比  \n",
       "金牌排名                          \n",
       "1        72     74  0.114706  \n",
       "2        56     50  0.111765  \n",
       "3        44     31  0.079412  \n",
       "4        44     43  0.064706  \n",
       "5        43     51  0.058824  \n",
       "...     ...    ...       ...  \n",
       "86        1      1  0.000000  \n",
       "86        1      1  0.000000  \n",
       "86        1      1  0.000000  \n",
       "86        1      1  0.000000  \n",
       "86        1      1  0.000000  \n",
       "\n",
       "[93 rows x 14 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop(len(df) -1, axis=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 18 - <font color ='#27BE49'>数据删除</font>｜删除行（条件）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 19 - <font color ='#27BE49'>数据删除</font>｜删除列\n",
    "\n",
    "<br>\n",
    "\n",
    "删除刚刚新增的 比赛地点 列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>金银牌总数</th>\n",
       "      <th>最多奖牌数量</th>\n",
       "      <th>金牌数大于30</th>\n",
       "      <th>金铜牌总数</th>\n",
       "      <th>银铜牌总数</th>\n",
       "      <th>金牌占比</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>80</td>\n",
       "      <td>41</td>\n",
       "      <td>是</td>\n",
       "      <td>72</td>\n",
       "      <td>74</td>\n",
       "      <td>0.114706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>70</td>\n",
       "      <td>38</td>\n",
       "      <td>是</td>\n",
       "      <td>56</td>\n",
       "      <td>50</td>\n",
       "      <td>0.111765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>41</td>\n",
       "      <td>27</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>31</td>\n",
       "      <td>0.079412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>43</td>\n",
       "      <td>22</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>43</td>\n",
       "      <td>0.064706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>48</td>\n",
       "      <td>28</td>\n",
       "      <td>否</td>\n",
       "      <td>43</td>\n",
       "      <td>51</td>\n",
       "      <td>0.058824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>93</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>9</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>13.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>94 rows × 13 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码  金银牌总数  最多奖牌数量 金牌数大于30  金铜牌总数  \\\n",
       "金牌排名                                                                          \n",
       "1       美国   39   41   33  113      1     USA     80      41       是     72   \n",
       "2       中国   38   32   18   88      2     CHN     70      38       是     56   \n",
       "3       日本   27   14   17   58      5     JPN     41      27       否     44   \n",
       "4       英国   22   21   22   65      4     GBR     43      22       否     44   \n",
       "5     俄奥委会   20   28   23   71      3     ROC     48      28       否     43   \n",
       "...    ...  ...  ...  ...  ...    ...     ...    ...     ...     ...    ...   \n",
       "86    格林纳达    0    0    1    1     77     GRN      0       1       否      1   \n",
       "86     科威特    0    0    1    1     77     KUW      0       1       否      1   \n",
       "86    摩尔多瓦    0    0    1    1     77     MDA      0       1       否      1   \n",
       "86     叙利亚    0    0    1    1     77     SYR      0       1       否      1   \n",
       "93       0    1    2    3    4      5       6      8       9      10     11   \n",
       "\n",
       "      银铜牌总数       金牌占比  \n",
       "金牌排名                    \n",
       "1        74   0.114706  \n",
       "2        50   0.111765  \n",
       "3        31   0.079412  \n",
       "4        43   0.064706  \n",
       "5        51   0.058824  \n",
       "...     ...        ...  \n",
       "86        1   0.000000  \n",
       "86        1   0.000000  \n",
       "86        1   0.000000  \n",
       "86        1   0.000000  \n",
       "93       12  13.000000  \n",
       "\n",
       "[94 rows x 13 columns]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop(columns=['比赛地点'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 20 - <font color ='#27BE49'>数据删除</font>｜删除列（按列号）\n",
    "\n",
    "<br>\n",
    "\n",
    "删除 `df` 的 `7、8、9、10` 列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "      <th>金牌数大于30</th>\n",
       "      <th>金铜牌总数</th>\n",
       "      <th>银铜牌总数</th>\n",
       "      <th>金牌占比</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "      <td>是</td>\n",
       "      <td>72</td>\n",
       "      <td>74</td>\n",
       "      <td>0.114706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "      <td>是</td>\n",
       "      <td>56</td>\n",
       "      <td>50</td>\n",
       "      <td>0.111765</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>31</td>\n",
       "      <td>0.079412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "      <td>否</td>\n",
       "      <td>44</td>\n",
       "      <td>43</td>\n",
       "      <td>0.064706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>俄奥委会</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "      <td>否</td>\n",
       "      <td>43</td>\n",
       "      <td>51</td>\n",
       "      <td>0.058824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "      <td>否</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>93</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>12</td>\n",
       "      <td>13.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>94 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码 金牌数大于30  金铜牌总数  银铜牌总数       金牌占比\n",
       "金牌排名                                                                          \n",
       "1       美国   39   41   33  113      1     USA       是     72     74   0.114706\n",
       "2       中国   38   32   18   88      2     CHN       是     56     50   0.111765\n",
       "3       日本   27   14   17   58      5     JPN       否     44     31   0.079412\n",
       "4       英国   22   21   22   65      4     GBR       否     44     43   0.064706\n",
       "5     俄奥委会   20   28   23   71      3     ROC       否     43     51   0.058824\n",
       "...    ...  ...  ...  ...  ...    ...     ...     ...    ...    ...        ...\n",
       "86    格林纳达    0    0    1    1     77     GRN       否      1      1   0.000000\n",
       "86     科威特    0    0    1    1     77     KUW       否      1      1   0.000000\n",
       "86    摩尔多瓦    0    0    1    1     77     MDA       否      1      1   0.000000\n",
       "86     叙利亚    0    0    1    1     77     SYR       否      1      1   0.000000\n",
       "93       0    1    2    3    4      5       6      10     11     12  13.000000\n",
       "\n",
       "[94 rows x 11 columns]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop(columns=df.columns[7:10])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5-2 数据筛选\n",
    "\n",
    "以下所有答案要求返回的是一个 dataframe 而不是 Series 这样可以直接存储为 Excel 等格式的文件！"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 21 - 重新加载数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "#df = pd.read_html(\"https://olympics.com/tokyo-2020/olympic-games/zh/results/all-sports/medal-standings.htm\")[0]\n",
    "\n",
    "df = pd.read_csv(\"东京奥运会奖牌数据.csv\")  # 如果未联网可以使用这条命令加载数据\n",
    "\n",
    "df.rename(columns={'Unnamed: 2':'金牌数',\n",
    "                  'Unnamed: 3':'银牌数',\n",
    "                  'Unnamed: 4':'铜牌数'},inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### 22 - <font color = '#FB8E00'>筛选列</font>｜通过列号\n",
    "\n",
    "提取第 1、2、3、4 列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   排名 国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0   1    美国   39   41   33  113      1     USA\n",
       "1   2    中国   38   32   18   88      2     CHN\n",
       "2   3    日本   27   14   17   58      5     JPN\n",
       "3   4    英国   22   21   22   65      4     GBR"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[0:4]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 23 - <font color = '#FB8E00'>筛选列</font>｜通过列名\n",
    "\n",
    "提取 `金牌数、银牌数、铜牌数` 三列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    金牌数  银牌数  铜牌数\n",
       "0    39   41   33\n",
       "1    38   32   18\n",
       "2    27   14   17\n",
       "3    22   21   22\n",
       "4    20   28   23\n",
       "..  ...  ...  ...\n",
       "88    0    0    1\n",
       "89    0    0    1\n",
       "90    0    0    1\n",
       "91    0    0    1\n",
       "92    0    0    1\n",
       "\n",
       "[93 rows x 3 columns]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[['金牌数','银牌数','铜牌数']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 24 - <font color = '#FB8E00'>筛选列</font>｜条件（列号）\n",
    "\n",
    "筛选全部 **奇数列**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>澳大利亚</td>\n",
       "      <td>17</td>\n",
       "      <td>7</td>\n",
       "      <td>22</td>\n",
       "      <td>46</td>\n",
       "      <td>6</td>\n",
       "      <td>AUS</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>法国</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "      <td>33</td>\n",
       "      <td>10</td>\n",
       "      <td>FRA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>意大利</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>40</td>\n",
       "      <td>7</td>\n",
       "      <td>ITA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>12</td>\n",
       "      <td>巴西</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>21</td>\n",
       "      <td>12</td>\n",
       "      <td>BRA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>14</td>\n",
       "      <td>古巴</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>15</td>\n",
       "      <td>18</td>\n",
       "      <td>CUB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>16</td>\n",
       "      <td>韩国</td>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>KOR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>18</td>\n",
       "      <td>捷克</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>11</td>\n",
       "      <td>23</td>\n",
       "      <td>CZE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>20</td>\n",
       "      <td>挪威</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>29</td>\n",
       "      <td>NOR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>22</td>\n",
       "      <td>西班牙</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>17</td>\n",
       "      <td>17</td>\n",
       "      <td>ESP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>24</td>\n",
       "      <td>瑞士</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>13</td>\n",
       "      <td>20</td>\n",
       "      <td>SUI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>26</td>\n",
       "      <td>克罗地亚</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>29</td>\n",
       "      <td>CRO</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>28</td>\n",
       "      <td>塞尔维亚</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>26</td>\n",
       "      <td>SRB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>30</td>\n",
       "      <td>保加利亚</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>39</td>\n",
       "      <td>BUL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>32</td>\n",
       "      <td>乌兹别克斯坦</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>42</td>\n",
       "      <td>UZB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>34</td>\n",
       "      <td>中华台北</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>12</td>\n",
       "      <td>22</td>\n",
       "      <td>TPE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>36</td>\n",
       "      <td>希腊</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>GRE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>38</td>\n",
       "      <td>厄瓜多尔</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>ECU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>39</td>\n",
       "      <td>以色列</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>ISR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>42</td>\n",
       "      <td>巴哈马</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>BAH</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>44</td>\n",
       "      <td>乌克兰</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>12</td>\n",
       "      <td>19</td>\n",
       "      <td>16</td>\n",
       "      <td>UKR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>46</td>\n",
       "      <td>罗马尼亚</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>ROU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>48</td>\n",
       "      <td>印度</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>33</td>\n",
       "      <td>IND</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>50</td>\n",
       "      <td>菲律宾</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>PHI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>52</td>\n",
       "      <td>南非</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>RSA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>54</td>\n",
       "      <td>埃及</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>39</td>\n",
       "      <td>EGY</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>56</td>\n",
       "      <td>埃塞俄比亚</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>ETH</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>58</td>\n",
       "      <td>突尼斯</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>TUN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>59</td>\n",
       "      <td>斐济</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>FIJ</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>59</td>\n",
       "      <td>泰国</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>THA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>63</th>\n",
       "      <td>63</td>\n",
       "      <td>摩洛哥</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MAR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>65</th>\n",
       "      <td>66</td>\n",
       "      <td>哥伦比亚</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>42</td>\n",
       "      <td>COL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67</th>\n",
       "      <td>68</td>\n",
       "      <td>多米尼加</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>42</td>\n",
       "      <td>DOM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>70</td>\n",
       "      <td>吉尔吉斯斯坦</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>KGZ</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>72</td>\n",
       "      <td>阿根廷</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>ARG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>73</th>\n",
       "      <td>74</td>\n",
       "      <td>约旦</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>JOR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75</th>\n",
       "      <td>74</td>\n",
       "      <td>尼日利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>NGR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>77</td>\n",
       "      <td>沙特阿拉伯</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KSA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>79</th>\n",
       "      <td>77</td>\n",
       "      <td>北马其顿</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MKD</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>81</th>\n",
       "      <td>77</td>\n",
       "      <td>土库曼斯坦</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>TKM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83</th>\n",
       "      <td>84</td>\n",
       "      <td>墨西哥</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>MEX</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>85</th>\n",
       "      <td>86</td>\n",
       "      <td>博茨瓦纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>BOT</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>86</td>\n",
       "      <td>科特迪瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>CIV</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>86</td>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>86</td>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    排名   国家奥委会  金牌数  银牌数  铜牌数  总分  按总数排名 国家奥委会代码\n",
       "1    2      中国   38   32   18  88      2     CHN\n",
       "3    4      英国   22   21   22  65      4     GBR\n",
       "5    6    澳大利亚   17    7   22  46      6     AUS\n",
       "7    8      法国   10   12   11  33     10     FRA\n",
       "9   10     意大利   10   10   20  40      7     ITA\n",
       "11  12      巴西    7    6    8  21     12     BRA\n",
       "13  14      古巴    7    3    5  15     18     CUB\n",
       "15  16      韩国    6    4   10  20     13     KOR\n",
       "17  18      捷克    4    4    3  11     23     CZE\n",
       "19  20      挪威    4    2    2   8     29     NOR\n",
       "21  22     西班牙    3    8    6  17     17     ESP\n",
       "23  24      瑞士    3    4    6  13     20     SUI\n",
       "25  26    克罗地亚    3    3    2   8     29     CRO\n",
       "27  28    塞尔维亚    3    1    5   9     26     SRB\n",
       "29  30    保加利亚    3    1    2   6     39     BUL\n",
       "31  32  乌兹别克斯坦    3    0    2   5     42     UZB\n",
       "33  34    中华台北    2    4    6  12     22     TPE\n",
       "35  36      希腊    2    1    1   4     47     GRE\n",
       "37  38    厄瓜多尔    2    1    0   3     60     ECU\n",
       "39  39     以色列    2    0    2   4     47     ISR\n",
       "41  42     巴哈马    2    0    0   2     66     BAH\n",
       "43  44     乌克兰    1    6   12  19     16     UKR\n",
       "45  46    罗马尼亚    1    3    0   4     47     ROU\n",
       "47  48      印度    1    2    4   7     33     IND\n",
       "49  50     菲律宾    1    2    1   4     47     PHI\n",
       "51  52      南非    1    2    0   3     60     RSA\n",
       "53  54      埃及    1    1    4   6     39     EGY\n",
       "55  56   埃塞俄比亚    1    1    2   4     47     ETH\n",
       "57  58     突尼斯    1    1    0   2     66     TUN\n",
       "59  59      斐济    1    0    1   2     66     FIJ\n",
       "61  59      泰国    1    0    1   2     66     THA\n",
       "63  63     摩洛哥    1    0    0   1     77     MAR\n",
       "65  66    哥伦比亚    0    4    1   5     42     COL\n",
       "67  68    多米尼加    0    3    2   5     42     DOM\n",
       "69  70  吉尔吉斯斯坦    0    2    1   3     60     KGZ\n",
       "71  72     阿根廷    0    1    2   3     60     ARG\n",
       "73  74      约旦    0    1    1   2     66     JOR\n",
       "75  74    尼日利亚    0    1    1   2     66     NGR\n",
       "77  77   沙特阿拉伯    0    1    0   1     77     KSA\n",
       "79  77    北马其顿    0    1    0   1     77     MKD\n",
       "81  77   土库曼斯坦    0    1    0   1     77     TKM\n",
       "83  84     墨西哥    0    0    4   4     47     MEX\n",
       "85  86    博茨瓦纳    0    0    1   1     77     BOT\n",
       "87  86    科特迪瓦    0    0    1   1     77     CIV\n",
       "89  86    格林纳达    0    0    1   1     77     GRN\n",
       "91  86    摩尔多瓦    0    0    1   1     77     MDA"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.index % 2 == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 25 - <font color = '#FB8E00'>筛选列</font>｜条件（列名）\n",
    "\n",
    "提取全部列名中包含 数 的列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>按总数排名</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>93 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    金牌数  银牌数  铜牌数  按总数排名\n",
       "0    39   41   33      1\n",
       "1    38   32   18      2\n",
       "2    27   14   17      5\n",
       "3    22   21   22      4\n",
       "4    20   28   23      3\n",
       "..  ...  ...  ...    ...\n",
       "88    0    0    1     77\n",
       "89    0    0    1     77\n",
       "90    0    0    1     77\n",
       "91    0    0    1     77\n",
       "92    0    0    1     77\n",
       "\n",
       "[93 rows x 4 columns]"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[:, df.columns[df.columns.str.contains(\"数\")]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 26 - <font color = '#FB8E00'>筛选列</font>｜组合（行号+列名）\n",
    "\n",
    "提取倒数后三列的10-20行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>24</td>\n",
       "      <td>11</td>\n",
       "      <td>CAN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>21</td>\n",
       "      <td>12</td>\n",
       "      <td>BRA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>NZL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>15</td>\n",
       "      <td>18</td>\n",
       "      <td>CUB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>HUN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>KOR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>14</td>\n",
       "      <td>19</td>\n",
       "      <td>POL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>11</td>\n",
       "      <td>23</td>\n",
       "      <td>CZE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>10</td>\n",
       "      <td>25</td>\n",
       "      <td>KEN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>8</td>\n",
       "      <td>29</td>\n",
       "      <td>NOR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    总分  按总数排名 国家奥委会代码\n",
       "10  24     11     CAN\n",
       "11  21     12     BRA\n",
       "12  20     13     NZL\n",
       "13  15     18     CUB\n",
       "14  20     13     HUN\n",
       "15  20     13     KOR\n",
       "16  14     19     POL\n",
       "17  11     23     CZE\n",
       "18  10     25     KEN\n",
       "19   8     29     NOR"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#df[10:20][df.columns[-3:]]\n",
    "df.iloc[10:20, -3:]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 27 - <font color = '#1B85FF' >筛选行</font>｜通过行号\n",
    "\n",
    "提取第 10 行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>意大利</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>40</td>\n",
       "      <td>7</td>\n",
       "      <td>ITA</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   排名 国家奥委会  金牌数  银牌数  铜牌数  总分  按总数排名 国家奥委会代码\n",
       "9  10   意大利   10   10   20  40      7     ITA"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[9:10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 28 -  <font color = '#1B85FF' >筛选行</font>｜通过行号（多行）\n",
    "\n",
    "提取第 10 行之后的全部行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  国家奥委会  金牌数\n",
       "0    美国   39\n",
       "1    中国   38\n",
       "2    日本   27"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#df.iloc[10:]\n",
    "df.iloc[:3, 1:3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 29 - <font color = '#1B85FF' >筛选行</font>｜固定间隔\n",
    "\n",
    "提取 0-50 行，间隔为 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>荷兰</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "      <td>36</td>\n",
       "      <td>9</td>\n",
       "      <td>NED</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>意大利</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>40</td>\n",
       "      <td>7</td>\n",
       "      <td>ITA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>13</td>\n",
       "      <td>新西兰</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>NZL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>16</td>\n",
       "      <td>韩国</td>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>KOR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>19</td>\n",
       "      <td>肯尼亚</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "      <td>25</td>\n",
       "      <td>KEN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>22</td>\n",
       "      <td>西班牙</td>\n",
       "      <td>3</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>17</td>\n",
       "      <td>17</td>\n",
       "      <td>ESP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>25</td>\n",
       "      <td>丹麦</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>11</td>\n",
       "      <td>23</td>\n",
       "      <td>DEN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>28</td>\n",
       "      <td>塞尔维亚</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>26</td>\n",
       "      <td>SRB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>31</td>\n",
       "      <td>斯洛文尼亚</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>42</td>\n",
       "      <td>SLO</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>34</td>\n",
       "      <td>中华台北</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>12</td>\n",
       "      <td>22</td>\n",
       "      <td>TPE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>36</td>\n",
       "      <td>乌干达</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>UGA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39</th>\n",
       "      <td>39</td>\n",
       "      <td>以色列</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>ISR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>42</td>\n",
       "      <td>科索沃</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>KOS</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>46</td>\n",
       "      <td>罗马尼亚</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>ROU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>49</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>39</td>\n",
       "      <td>HKG</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    排名  国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0    1     美国   39   41   33  113      1     USA\n",
       "3    4     英国   22   21   22   65      4     GBR\n",
       "6    7     荷兰   10   12   14   36      9     NED\n",
       "9   10    意大利   10   10   20   40      7     ITA\n",
       "12  13    新西兰    7    6    7   20     13     NZL\n",
       "15  16     韩国    6    4   10   20     13     KOR\n",
       "18  19    肯尼亚    4    4    2   10     25     KEN\n",
       "21  22    西班牙    3    8    6   17     17     ESP\n",
       "24  25     丹麦    3    4    4   11     23     DEN\n",
       "27  28   塞尔维亚    3    1    5    9     26     SRB\n",
       "30  31  斯洛文尼亚    3    1    1    5     42     SLO\n",
       "33  34   中华台北    2    4    6   12     22     TPE\n",
       "36  36    乌干达    2    1    1    4     47     UGA\n",
       "39  39    以色列    2    0    2    4     47     ISR\n",
       "42  42    科索沃    2    0    0    2     66     KOS\n",
       "45  46   罗马尼亚    1    3    0    4     47     ROU\n",
       "48  49   中国香港    1    2    3    6     39     HKG"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[0:50:3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 30 -  <font color = '#1B85FF' >筛选行</font>｜判断（大于）\n",
    "\n",
    "提取 金牌数 大于 30 的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   排名 国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0   1    美国   39   41   33  113      1     USA\n",
       "1   2    中国   38   32   18   88      2     CHN"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#df.query('金牌数 > 30')\n",
    "df[df.金牌数 > 30]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 31 -  <font color = '#1B85FF' >筛选行 </font>｜判断（等于）\n",
    "\n",
    "提取 `金牌数` 等于 10 的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>荷兰</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "      <td>36</td>\n",
       "      <td>9</td>\n",
       "      <td>NED</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>法国</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "      <td>33</td>\n",
       "      <td>10</td>\n",
       "      <td>FRA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>德国</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>16</td>\n",
       "      <td>37</td>\n",
       "      <td>8</td>\n",
       "      <td>GER</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>意大利</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>40</td>\n",
       "      <td>7</td>\n",
       "      <td>ITA</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   排名 国家奥委会  金牌数  银牌数  铜牌数  总分  按总数排名 国家奥委会代码\n",
       "6   7    荷兰   10   12   14  36      9     NED\n",
       "7   8    法国   10   12   11  33     10     FRA\n",
       "8   9    德国   10   11   16  37      8     GER\n",
       "9  10   意大利   10   10   20  40      7     ITA"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#df.query('金牌数 == 10')\n",
    "df[df.金牌数 == 10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 32 - <font color = '#1B85FF' >筛选行</font>｜判断（不等于）\n",
    "\n",
    "提取 `金牌数` 不等于 `10` 的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>86</td>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>86</td>\n",
       "      <td>格林纳达</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>86</td>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>86</td>\n",
       "      <td>摩尔多瓦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>MDA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>86</td>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>89 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    排名 国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0    1    美国   39   41   33  113      1     USA\n",
       "1    2    中国   38   32   18   88      2     CHN\n",
       "2    3    日本   27   14   17   58      5     JPN\n",
       "3    4    英国   22   21   22   65      4     GBR\n",
       "4    5   ROC   20   28   23   71      3     ROC\n",
       "..  ..   ...  ...  ...  ...  ...    ...     ...\n",
       "88  86    加纳    0    0    1    1     77     GHA\n",
       "89  86  格林纳达    0    0    1    1     77     GRN\n",
       "90  86   科威特    0    0    1    1     77     KUW\n",
       "91  86  摩尔多瓦    0    0    1    1     77     MDA\n",
       "92  86   叙利亚    0    0    1    1     77     SYR\n",
       "\n",
       "[89 rows x 8 columns]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.金牌数 != 10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 33 - <font color = '#1B85FF' >筛选行</font>｜条件（指定行号）\n",
    "\n",
    "提取全部 **奇数行**\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>荷兰</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "      <td>36</td>\n",
       "      <td>9</td>\n",
       "      <td>NED</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>德国</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>16</td>\n",
       "      <td>37</td>\n",
       "      <td>8</td>\n",
       "      <td>GER</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>11</td>\n",
       "      <td>加拿大</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>11</td>\n",
       "      <td>24</td>\n",
       "      <td>11</td>\n",
       "      <td>CAN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>13</td>\n",
       "      <td>新西兰</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>NZL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>15</td>\n",
       "      <td>匈牙利</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>HUN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>17</td>\n",
       "      <td>波兰</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>14</td>\n",
       "      <td>19</td>\n",
       "      <td>POL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>19</td>\n",
       "      <td>肯尼亚</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "      <td>25</td>\n",
       "      <td>KEN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>21</td>\n",
       "      <td>牙买加</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>9</td>\n",
       "      <td>26</td>\n",
       "      <td>JAM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>23</td>\n",
       "      <td>瑞典</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>26</td>\n",
       "      <td>SWE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>25</td>\n",
       "      <td>丹麦</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>11</td>\n",
       "      <td>23</td>\n",
       "      <td>DEN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>27</td>\n",
       "      <td>伊朗</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>33</td>\n",
       "      <td>IRI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>29</td>\n",
       "      <td>比利时</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>33</td>\n",
       "      <td>BEL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>31</td>\n",
       "      <td>斯洛文尼亚</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>42</td>\n",
       "      <td>SLO</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>33</td>\n",
       "      <td>格鲁吉亚</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>8</td>\n",
       "      <td>29</td>\n",
       "      <td>GEO</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>35</td>\n",
       "      <td>土耳其</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>9</td>\n",
       "      <td>13</td>\n",
       "      <td>20</td>\n",
       "      <td>TUR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>36</td>\n",
       "      <td>乌干达</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>UGA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38</th>\n",
       "      <td>39</td>\n",
       "      <td>爱尔兰</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>IRL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>41</td>\n",
       "      <td>卡塔尔</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>QAT</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>42</td>\n",
       "      <td>科索沃</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>KOS</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>45</td>\n",
       "      <td>白俄罗斯</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>33</td>\n",
       "      <td>BLR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>46</td>\n",
       "      <td>委内瑞拉</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>VEN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>49</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>39</td>\n",
       "      <td>HKG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>50</td>\n",
       "      <td>斯洛伐克</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>SVK</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>53</td>\n",
       "      <td>奥地利</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>7</td>\n",
       "      <td>33</td>\n",
       "      <td>AUT</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>55</td>\n",
       "      <td>印度尼西亚</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>42</td>\n",
       "      <td>INA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>56</td>\n",
       "      <td>葡萄牙</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>POR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>59</td>\n",
       "      <td>爱沙尼亚</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>EST</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>59</td>\n",
       "      <td>拉脱维亚</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>LAT</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62</th>\n",
       "      <td>63</td>\n",
       "      <td>百慕大</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>BER</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>63</td>\n",
       "      <td>波多黎各</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>PUR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66</th>\n",
       "      <td>67</td>\n",
       "      <td>阿塞拜疆</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>33</td>\n",
       "      <td>AZE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68</th>\n",
       "      <td>69</td>\n",
       "      <td>亚美尼亚</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>ARM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>71</td>\n",
       "      <td>蒙古</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>47</td>\n",
       "      <td>MGL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>72</td>\n",
       "      <td>圣马力诺</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>SMR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>74</td>\n",
       "      <td>马来西亚</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>MAS</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>76</th>\n",
       "      <td>77</td>\n",
       "      <td>巴林</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>BRN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>77</td>\n",
       "      <td>立陶宛</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>LTU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80</th>\n",
       "      <td>77</td>\n",
       "      <td>纳米比亚</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>NAM</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>82</th>\n",
       "      <td>83</td>\n",
       "      <td>哈萨克斯坦</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>29</td>\n",
       "      <td>KAZ</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>84</th>\n",
       "      <td>85</td>\n",
       "      <td>芬兰</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>FIN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>86</td>\n",
       "      <td>布基纳法索</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>BUR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>86</td>\n",
       "      <td>加纳</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>GHA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>86</td>\n",
       "      <td>科威特</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>KUW</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>86</td>\n",
       "      <td>叙利亚</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>SYR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    排名  国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0    1     美国   39   41   33  113      1     USA\n",
       "2    3     日本   27   14   17   58      5     JPN\n",
       "4    5    ROC   20   28   23   71      3     ROC\n",
       "6    7     荷兰   10   12   14   36      9     NED\n",
       "8    9     德国   10   11   16   37      8     GER\n",
       "10  11    加拿大    7    6   11   24     11     CAN\n",
       "12  13    新西兰    7    6    7   20     13     NZL\n",
       "14  15    匈牙利    6    7    7   20     13     HUN\n",
       "16  17     波兰    4    5    5   14     19     POL\n",
       "18  19    肯尼亚    4    4    2   10     25     KEN\n",
       "20  21    牙买加    4    1    4    9     26     JAM\n",
       "22  23     瑞典    3    6    0    9     26     SWE\n",
       "24  25     丹麦    3    4    4   11     23     DEN\n",
       "26  27     伊朗    3    2    2    7     33     IRI\n",
       "28  29    比利时    3    1    3    7     33     BEL\n",
       "30  31  斯洛文尼亚    3    1    1    5     42     SLO\n",
       "32  33   格鲁吉亚    2    5    1    8     29     GEO\n",
       "34  35    土耳其    2    2    9   13     20     TUR\n",
       "36  36    乌干达    2    1    1    4     47     UGA\n",
       "38  39    爱尔兰    2    0    2    4     47     IRL\n",
       "40  41    卡塔尔    2    0    1    3     60     QAT\n",
       "42  42    科索沃    2    0    0    2     66     KOS\n",
       "44  45   白俄罗斯    1    3    3    7     33     BLR\n",
       "46  46   委内瑞拉    1    3    0    4     47     VEN\n",
       "48  49   中国香港    1    2    3    6     39     HKG\n",
       "50  50   斯洛伐克    1    2    1    4     47     SVK\n",
       "52  53    奥地利    1    1    5    7     33     AUT\n",
       "54  55  印度尼西亚    1    1    3    5     42     INA\n",
       "56  56    葡萄牙    1    1    2    4     47     POR\n",
       "58  59   爱沙尼亚    1    0    1    2     66     EST\n",
       "60  59   拉脱维亚    1    0    1    2     66     LAT\n",
       "62  63    百慕大    1    0    0    1     77     BER\n",
       "64  63   波多黎各    1    0    0    1     77     PUR\n",
       "66  67   阿塞拜疆    0    3    4    7     33     AZE\n",
       "68  69   亚美尼亚    0    2    2    4     47     ARM\n",
       "70  71     蒙古    0    1    3    4     47     MGL\n",
       "72  72   圣马力诺    0    1    2    3     60     SMR\n",
       "74  74   马来西亚    0    1    1    2     66     MAS\n",
       "76  77     巴林    0    1    0    1     77     BRN\n",
       "78  77    立陶宛    0    1    0    1     77     LTU\n",
       "80  77   纳米比亚    0    1    0    1     77     NAM\n",
       "82  83  哈萨克斯坦    0    0    8    8     29     KAZ\n",
       "84  85     芬兰    0    0    2    2     66     FIN\n",
       "86  86  布基纳法索    0    0    1    1     77     BUR\n",
       "88  86     加纳    0    0    1    1     77     GHA\n",
       "90  86    科威特    0    0    1    1     77     KUW\n",
       "92  86    叙利亚    0    0    1    1     77     SYR"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[::2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 34 - <font color = '#1B85FF' >筛选行</font>｜条件（指定值）\n",
    "\n",
    "\n",
    "提取 中国、美国、英国 三行数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   排名 国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0   1    美国   39   41   33  113      1     USA\n",
       "1   2    中国   38   32   18   88      2     CHN\n",
       "3   4    英国   22   21   22   65      4     GBR"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#df.query(\"国家奥委会 =='中国' or 国家奥委会 == '美国'  or 国家奥委会 == '英国'\")\n",
    "#df[(df.国家奥委会 == '中国') | (df.国家奥委会 == '美国') | (df.国家奥委会 == '英国')]\n",
    "\n",
    "df[df['国家奥委会'].isin(['中国','美国','英国'])]\n",
    "#df[df['国家奥委会'].apply(lambda x: True if x in ['中国','美国','英国'] else False)]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 35 -  <font color = '#1B85FF' >筛选行</font>｜多条件\n",
    "\n",
    "在上一题的条件下，新增一个条件：**金牌数小于30**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   排名 国家奥委会  金牌数  银牌数  铜牌数  总分  按总数排名 国家奥委会代码\n",
       "3   4    英国   22   21   22  65      4     GBR"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df['国家奥委会'].isin(['中国','美国','英国']) & (df.金牌数 < 30)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 36 - <font color = '#1B85FF' >筛选行</font>｜条件（包含指定值）\n",
    "\n",
    "提取 国家奥委会 列中，所有包含 `国`的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>法国</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "      <td>33</td>\n",
       "      <td>10</td>\n",
       "      <td>FRA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>德国</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>16</td>\n",
       "      <td>37</td>\n",
       "      <td>8</td>\n",
       "      <td>GER</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>16</td>\n",
       "      <td>韩国</td>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>KOR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>49</td>\n",
       "      <td>中国香港</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>39</td>\n",
       "      <td>HKG</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>59</td>\n",
       "      <td>泰国</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>66</td>\n",
       "      <td>THA</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    排名 国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0    1    美国   39   41   33  113      1     USA\n",
       "1    2    中国   38   32   18   88      2     CHN\n",
       "3    4    英国   22   21   22   65      4     GBR\n",
       "7    8    法国   10   12   11   33     10     FRA\n",
       "8    9    德国   10   11   16   37      8     GER\n",
       "15  16    韩国    6    4   10   20     13     KOR\n",
       "48  49  中国香港    1    2    3    6     39     HKG\n",
       "61  59    泰国    1    0    1    2     66     THA"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.国家奥委会.str.contains('国')]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 37 - 筛选某行某列\n",
    "\n",
    "提取 `第 0 行第 2 列`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>美国</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  国家奥委会\n",
       "0    美国"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[0:1, [1]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 38 - 筛选多行多列\n",
    "\n",
    "\n",
    "提取 第 0-2 行第 0-2 列\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 446,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     国家奥委会  金牌数  银牌数\n",
       "金牌排名                \n",
       "1       美国   39   41\n",
       "2       中国   38   32\n",
       "3       日本   27   14"
      ]
     },
     "execution_count": 446,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[0:3, 0:3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 39 - <font color ='#27BE49'>筛选值</font>｜组合（行号+列号）\n",
    "\n",
    "提取第 4 行，第 4 列的值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 449,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>总分</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>71</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      总分\n",
       "金牌排名    \n",
       "5     71"
      ]
     },
     "execution_count": 449,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[[4],[4]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  40 - <font color ='#27BE49'>筛选值</font>｜组合（行号+列名）\n",
    "\n",
    "提取行索引为 4 ，列名为 金牌数 的值\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 460,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>金牌数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>金牌排名</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      金牌数\n",
       "金牌排名     \n",
       "4      22"
      ]
     },
     "execution_count": 460,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[4:4, ['金牌数']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 41 - <font color ='#27BE49'>筛选值</font>｜条件\n",
    "\n",
    "提取 国家奥委会 为 中国 的金牌数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 462,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "金牌排名\n",
       "2    38\n",
       "Name: 金牌数, dtype: int64"
      ]
     },
     "execution_count": 462,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.国家奥委会 == '中国']['金牌数']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 42 - <font color ='#27BE49'>筛选值</font>｜query\n",
    "\n",
    "使用 query 提取 金牌数 + 银牌数 大于 15 的国家"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>澳大利亚</td>\n",
       "      <td>17</td>\n",
       "      <td>7</td>\n",
       "      <td>22</td>\n",
       "      <td>46</td>\n",
       "      <td>6</td>\n",
       "      <td>AUS</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>荷兰</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "      <td>36</td>\n",
       "      <td>9</td>\n",
       "      <td>NED</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>法国</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "      <td>33</td>\n",
       "      <td>10</td>\n",
       "      <td>FRA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>德国</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>16</td>\n",
       "      <td>37</td>\n",
       "      <td>8</td>\n",
       "      <td>GER</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>意大利</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>40</td>\n",
       "      <td>7</td>\n",
       "      <td>ITA</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   排名 国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0   1    美国   39   41   33  113      1     USA\n",
       "1   2    中国   38   32   18   88      2     CHN\n",
       "2   3    日本   27   14   17   58      5     JPN\n",
       "3   4    英国   22   21   22   65      4     GBR\n",
       "4   5   ROC   20   28   23   71      3     ROC\n",
       "5   6  澳大利亚   17    7   22   46      6     AUS\n",
       "6   7    荷兰   10   12   14   36      9     NED\n",
       "7   8    法国   10   12   11   33     10     FRA\n",
       "8   9    德国   10   11   16   37      8     GER\n",
       "9  10   意大利   10   10   20   40      7     ITA"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.query(\"金牌数 +  银牌数 > 15\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  43 - <font color ='#27BE49'>筛选值</font>｜query（引用变量）\n",
    "\n",
    "使用 query 提取 金牌数 大于 金牌均值的国家"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>排名</th>\n",
       "      <th>国家奥委会</th>\n",
       "      <th>金牌数</th>\n",
       "      <th>银牌数</th>\n",
       "      <th>铜牌数</th>\n",
       "      <th>总分</th>\n",
       "      <th>按总数排名</th>\n",
       "      <th>国家奥委会代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>美国</td>\n",
       "      <td>39</td>\n",
       "      <td>41</td>\n",
       "      <td>33</td>\n",
       "      <td>113</td>\n",
       "      <td>1</td>\n",
       "      <td>USA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>中国</td>\n",
       "      <td>38</td>\n",
       "      <td>32</td>\n",
       "      <td>18</td>\n",
       "      <td>88</td>\n",
       "      <td>2</td>\n",
       "      <td>CHN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>日本</td>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>17</td>\n",
       "      <td>58</td>\n",
       "      <td>5</td>\n",
       "      <td>JPN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>英国</td>\n",
       "      <td>22</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>65</td>\n",
       "      <td>4</td>\n",
       "      <td>GBR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>ROC</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>23</td>\n",
       "      <td>71</td>\n",
       "      <td>3</td>\n",
       "      <td>ROC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>澳大利亚</td>\n",
       "      <td>17</td>\n",
       "      <td>7</td>\n",
       "      <td>22</td>\n",
       "      <td>46</td>\n",
       "      <td>6</td>\n",
       "      <td>AUS</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>荷兰</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>14</td>\n",
       "      <td>36</td>\n",
       "      <td>9</td>\n",
       "      <td>NED</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>法国</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>11</td>\n",
       "      <td>33</td>\n",
       "      <td>10</td>\n",
       "      <td>FRA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>德国</td>\n",
       "      <td>10</td>\n",
       "      <td>11</td>\n",
       "      <td>16</td>\n",
       "      <td>37</td>\n",
       "      <td>8</td>\n",
       "      <td>GER</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>意大利</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>40</td>\n",
       "      <td>7</td>\n",
       "      <td>ITA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>11</td>\n",
       "      <td>加拿大</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>11</td>\n",
       "      <td>24</td>\n",
       "      <td>11</td>\n",
       "      <td>CAN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>12</td>\n",
       "      <td>巴西</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>8</td>\n",
       "      <td>21</td>\n",
       "      <td>12</td>\n",
       "      <td>BRA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>13</td>\n",
       "      <td>新西兰</td>\n",
       "      <td>7</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>NZL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>14</td>\n",
       "      <td>古巴</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>15</td>\n",
       "      <td>18</td>\n",
       "      <td>CUB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>15</td>\n",
       "      <td>匈牙利</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>HUN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>16</td>\n",
       "      <td>韩国</td>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>10</td>\n",
       "      <td>20</td>\n",
       "      <td>13</td>\n",
       "      <td>KOR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>17</td>\n",
       "      <td>波兰</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>14</td>\n",
       "      <td>19</td>\n",
       "      <td>POL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>18</td>\n",
       "      <td>捷克</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "      <td>11</td>\n",
       "      <td>23</td>\n",
       "      <td>CZE</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>19</td>\n",
       "      <td>肯尼亚</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>10</td>\n",
       "      <td>25</td>\n",
       "      <td>KEN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>20</td>\n",
       "      <td>挪威</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>29</td>\n",
       "      <td>NOR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>21</td>\n",
       "      <td>牙买加</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>9</td>\n",
       "      <td>26</td>\n",
       "      <td>JAM</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    排名 国家奥委会  金牌数  银牌数  铜牌数   总分  按总数排名 国家奥委会代码\n",
       "0    1    美国   39   41   33  113      1     USA\n",
       "1    2    中国   38   32   18   88      2     CHN\n",
       "2    3    日本   27   14   17   58      5     JPN\n",
       "3    4    英国   22   21   22   65      4     GBR\n",
       "4    5   ROC   20   28   23   71      3     ROC\n",
       "5    6  澳大利亚   17    7   22   46      6     AUS\n",
       "6    7    荷兰   10   12   14   36      9     NED\n",
       "7    8    法国   10   12   11   33     10     FRA\n",
       "8    9    德国   10   11   16   37      8     GER\n",
       "9   10   意大利   10   10   20   40      7     ITA\n",
       "10  11   加拿大    7    6   11   24     11     CAN\n",
       "11  12    巴西    7    6    8   21     12     BRA\n",
       "12  13   新西兰    7    6    7   20     13     NZL\n",
       "13  14    古巴    7    3    5   15     18     CUB\n",
       "14  15   匈牙利    6    7    7   20     13     HUN\n",
       "15  16    韩国    6    4   10   20     13     KOR\n",
       "16  17    波兰    4    5    5   14     19     POL\n",
       "17  18    捷克    4    4    3   11     23     CZE\n",
       "18  19   肯尼亚    4    4    2   10     25     KEN\n",
       "19  20    挪威    4    2    2    8     29     NOR\n",
       "20  21   牙买加    4    1    4    9     26     JAM"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "god_mean = df.金牌数.mean()\n",
    "df.query(\"金牌数 > \" + str(god_mean))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](http://liuzaoqi.oss-cn-beijing.aliyuncs.com/2021/09/16/16317972442543.jpg?域名/sample.jpg?x-oss-process=style/stylename)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
  },
  "kernelspec": {
   "display_name": "Python 3.7.3 64-bit",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "367px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
